﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Enterprise.Infrastructure;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Enterprise.Model.WorkFlow;
using Enterprise.DataFactory;
namespace Enterprise.Data.WorkFlow
{
    /// <summary>
    /// 流程节点数据操作
    /// </summary>
    public class WorkFlowNodeData
    {
        /// <summary>
        ///  流程数据列表
        /// </summary>
        /// <returns></returns>
        public List<WorkFlowNodeEntity> WorkFlowNodeList()
        {
            List<WorkFlowNodeEntity> list = new List<WorkFlowNodeEntity>();
            string cmd = "Select * from SYS_WORKFLOWNODE";
            IDataReader dr = DbExecute.DataReader(cmd);
            while (dr.Read())
            {
                WorkFlowNodeEntity entity = new WorkFlowNodeEntity();
                if (!Convert.IsDBNull(dr["NID"])) entity.NID = Convert.ToInt32(dr["NID"]);
                if (!Convert.IsDBNull(dr["WFID"])) entity.WFID = Convert.ToInt32(dr["WFID"]);
                if (!Convert.IsDBNull(dr["NNAME"])) entity.NNAME = Convert.ToString(dr["NNAME"]);
                if (!Convert.IsDBNull(dr["NTYPE"])) entity.NTYPE = Convert.ToInt32(dr["NTYPE"]);
                if (!Convert.IsDBNull(dr["NOBJECTTYPE"])) entity.NOBJECTTYPE = Convert.ToInt32(dr["NOBJECTTYPE"]);
                if (!Convert.IsDBNull(dr["NOBJECT"])) entity.NOBJECT = Convert.ToInt32(dr["NOBJECT"]);
                if (!Convert.IsDBNull(dr["NREMARK"])) entity.NREMARK = Convert.ToString(dr["NREMARK"]);
                if (!Convert.IsDBNull(dr["NORDERBY"])) entity.NORDERBY = Convert.ToInt32(dr["NORDERBY"]);
                list.Add(entity);
            }
            dr.Close();
            return list;
        }

        /// <summary>
        /// 流程数据操作方法
        /// </summary>
        /// <param name="cmd"></param>
        public void WorkFlowExecute(string cmd)
        {
            DbExecute.Execute(cmd);
        }

        /// <summary>
        /// 返回数据集合
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        public DataSet ExcuteDataSet(string cmd)
        {
            return DbExecute.GetDataSet(cmd);
        }
    }
}
